package managers;

import android.app.Service;
import android.content.Context;
import android.media.MediaPlayer;
import android.os.Vibrator;

import com.xkh.xkh.R;

/**
 * Created by 凯 on 2015/12/15.
 */
public class Vibreater {

    public static void Vibrate(final Context context, long milliseconds) {
        Vibrator vib = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
        vib.vibrate(milliseconds);
        MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.classic);
        mediaPlayer.setLooping(false);
        mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                mp.reset();
                mp.release();
            }
        });
        mediaPlayer.start();
    }
}
